package cn.wolfcode.wolf2w.business.test.service.impl;

import cn.wolfcode.wolf2w.business.service.LogisticsStrategy;
import cn.wolfcode.wolf2w.business.test.TradeOrder;

import java.math.BigDecimal;

public class WeighStrategy implements LogisticsStrategy {
    private BigDecimal weightStart;
    private BigDecimal weightEnd;
    private Long logisticsId;

    public WeighStrategy(BigDecimal weightStart, BigDecimal weightEnd, Long logisticsId) {
        this.weightStart = weightStart;
        this.weightEnd = weightEnd;
        this.logisticsId = logisticsId;
    }

    @Override
    public boolean match(TradeOrder order) {
        BigDecimal weight = order.getWeight();
        return weight.compareTo(weightStart) >= 0 && weight.compareTo(weightEnd) <= 0;
    }

    @Override
    public Long getLogisticsId() {
        return logisticsId;
    }
}